import requests
import json
from Base.PublicFunction import Requst

from Base.BaseSetting import url_path
class Employ_Management_SHL:
    def __init__(self):
        self.session=requests.session()
        url = url_path+ "/WoniuBoss4.0/login/userLogin"
        self.session=Requst.get_session()
        # print(self.session.cookies)

    def search_join_company(self,pagesize,city,cls_name):      #按条件搜索入职信息
        url=url_path+ "/WoniuBoss4.0/entryinfo/queryReByInfo"
        body=f"pageSize={pagesize}&pageIndex=1&regionId={city}&stuClass={cls_name}&orientation=%E5%85%AC%E5%85%B1&stuName=&stuNo="
        headers={'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8"}
        resobj=self.session.post(url=url, data=body, headers=headers)
        content=resobj.text
        # print(content)
        result=json.loads(content)
        # print(result)
        return result

    def add_cooperation_company(self,com_name,instury,address,contenter,phone):      #新增合作企业
        url=url_path +"/WoniuBoss4.0/enterprise/addEnterp" f"?ent.ent_name={com_name}&ent.ent_category={instury}&ent.ent_addr={address}&ent.ent_header={contenter}&ent.tel={phone}&ent.email=&ent.qq="
        resobj=self.session.get(url=url)
        content=resobj.text

        # print(resobj)
        # print(content)
        return content

    def add_student_salary(self,pageSize,pageIndex,region,stuClass):      #新增学员的薪水信息
        url=url_path+"/WoniuBoss4.0/entryinfo/queryReByInfo"
        body=f"pageSize={pageSize}&pageIndex={pageIndex}&regionId={region}&stuClass={stuClass}&orientation=%E5%85%AC%E5%85%B1&stuName=&stuNo="
        headers = {'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8"}
        resobj = self.session.post(url=url, data=body, headers=headers)
        content = resobj.text
        a=json.loads(content)
        # print(a)
        return a

    def alter_company_info(self,com_name,contenter):   #修改企业信息
        url=url_path +"/WoniuBoss4.0/enterprise/updateEnterp" f"?ent.enterprise_id=1294&ent.ent_name={com_name}&ent.ent_category=制药&ent.ent_addr=张东路12号&ent.ent_header={contenter}&ent.tel=15012125451&ent.email=&ent.qq="
        resobj = self.session.post(url=url)
        content = resobj.text
        # print(resobj)
        # print(content)
        return content

    def search_company(self,pagesize,index):       #输入企业名称搜索
        url=url_path +"/WoniuBoss4.0/enterprise/queryEnterprise"
        body=f"pageSize={pagesize}&pageIndex={index}&entName=%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4"
        headers = {'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8"}
        resobj = self.session.post(url=url, data=body, headers=headers)
        content = resobj.text
        a=json.loads(content)
        return a




if __name__ == '__main__':
    ru=Employ_Management_SHL()
    ru.search_join_company(10,1,"WN00000")
    ru.add_cooperation_company('张江药谷','制药',"张东路12号","王小姐","15012125451")
    ru.add_student_salary(10,1,1,'WN00000')
    ru.alter_company_info("中国烟草","李小姐")
    ru.search_company(10,1)











